﻿#include "stdafx.h"
#include "main_data_c.h"
#include "terrainLight.h"
#include "base/mgImage.h"

void readTerrainLight_Ozj_456030(const char* filename, float* outData)
{
	char pathBuf[260];
	PathCombine(pathBuf, "data", filename);
	PathRenameExtension(pathBuf, ".OZJ");
	mg::Image img;

	if (img.load(pathBuf, 0, true)) {
		int length = img.getDataSize();
		if (length != 256 * 256 * 3) return;

		BYTE* data = img.getData();
		for (size_t i = 0; i < length; i++)
		{
			*outData = (float)(*data) * 0.0039215689f;
			outData++;
			data++;
		}
	}
}

// 读取TerrainLight.jpg
void loadTerrainLight_43C460(const char* filename)
{
	readTerrainLight_Ozj_456030(filename, (float*)&mainData.terrainLightData_7D09970[0]);
	sub_43C2C0();
	sub_43C3D0();
}
